package com.zfy.tingshu.user.api;

import com.zfy.tingshu.common.login.TsLogin;
import com.zfy.tingshu.common.result.Result;
import com.zfy.tingshu.common.util.AuthContextHolder;
import com.zfy.tingshu.user.service.UserInfoService;
import com.zfy.tingshu.vo.album.AlbumTrackListVo;
import com.zfy.tingshu.vo.user.UserInfoVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Tag(name = "用户管理接口")
@RestController
@RequestMapping("api/user/userInfo")
@SuppressWarnings({"all"})
public class UserInfoApiController {

	@Autowired
	private UserInfoService userInfoService;


	/**
	 * 判断用户是否购买声音列表
	 * @param albumId
	 * @param trackIdList
	 * @return
	 */
	@TsLogin
	@Operation(summary = "判断用户是否购买声音列表")
	@PostMapping("/userIsPaidTrack/{albumId}")
	public Result<Map<Long,Integer>> userIsPaidTrack(@PathVariable("albumId")Long albumId, @RequestBody List<Long> trackIdList){
		//获取用户Id
		Long userId = AuthContextHolder.getUserId();
		//调用服务层方法
		Map<Long,Integer> map=userInfoService.userIsPaidTrack(albumId,trackIdList,userId);
		//返回结果
		return Result.ok(map);
	}

	/**
	 * 根据userId获取用户信息
	 * @param user_id
	 * @return
	 */
	@Operation(summary = "获取登录信息")
	@GetMapping("getUserInfo/{user_id}")
	public Result getUserInfo(@PathVariable("user_id") Long user_id) {
		//调用服务层方法
		UserInfoVo userInfoVo = userInfoService.getUserInfoVoByUserId(user_id);
		//返回数据
		return Result.ok(userInfoVo);
	}

}

